package com.punch.system.controller;


import com.punch.common.dto.system.TeacherLectureDTO;
import com.punch.common.model.Result;
import com.punch.common.page.PageInfo;
import com.punch.common.query.syste.TeacherLectureQueryInfo;
import com.punch.common.vo.system.TeacherLectureVO;
import com.punch.system.service.TeacherLectureService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 名师讲堂表 前端控制器
 * </p>
 *
 * @author wjj
 * @since 2020-12-14
 */
@RestController
@Api(value = "TeacherLectureController", tags = "名师讲堂管理Controller")
public class TeacherLectureController {


    @Resource
    private TeacherLectureService teacherLectureService;

    /**
     * 名师讲堂列表
     *
     * @param queryInfo 查询条件
     * @return PageInfo<TeacherLectureVO>
     */
    @GetMapping(value = "/teacher-lectures", produces = "application/json; charset=utf-8")
    @ApiOperation(value = "名师讲堂列表", notes = "名师讲堂列表", produces = "application/json")
    public Result<PageInfo<TeacherLectureVO>> listTeacherLecture(@ModelAttribute TeacherLectureQueryInfo queryInfo) {
        return Result.succeed(teacherLectureService.listTeacherLecture(queryInfo));
    }


    /**
     * 保存名师讲堂
     *
     * @param teacherLectureDTO 提交表单
     * @return id
     */
    @PostMapping(value = "/teacher-lecture", produces = "application/json; charset=utf-8")
    @ApiOperation(value = " 保存名师讲堂", notes = " 保存名师讲堂", produces = "application/json")
    public Result<Integer> saveTeacherLecture(@RequestBody TeacherLectureDTO teacherLectureDTO) {
        return Result.succeed(teacherLectureService.saveTeacherLecture(teacherLectureDTO));
    }

    /**
     * 修改名师讲堂
     *
     * @param teacherLectureDTO 提交表单
     * @return id
     */
    @PutMapping(value = "/teacher-lecture", produces = "application/json; charset=utf-8")
    @ApiOperation(value = " 修改名师讲堂", notes = " 修改名师讲堂", produces = "application/json")
    public Result<Integer> updateTeacherLecture(@RequestBody TeacherLectureDTO teacherLectureDTO) {
        return Result.succeed(teacherLectureService.updateTeacherLecture(teacherLectureDTO));
    }


    /**
     * 名师讲堂详情
     *
     * @param lectureId lectureId
     * @return TeacherLectureVO
     */
    @GetMapping(value = "/teacher-lecture/{lectureId}", produces = "application/json; charset=utf-8")
    @ApiOperation(value = "名师讲堂详情", notes = "名师讲堂详情", produces = "application/json")
    public Result<TeacherLectureVO> getTeacherLecture(@PathVariable Integer lectureId) {
        return Result.succeed(teacherLectureService.getTeacherLecture(lectureId));
    }

    /**
     * 删除名师讲堂
     *
     * @param lectureId lectureId
     * @return id
     */
    @DeleteMapping(value = "/teacher-lecture/{lectureId}", produces = "application/json; charset=utf-8")
    @ApiOperation(value = " 删除名师讲堂", notes = " 删除名师讲堂", produces = "application/json")
    public Result<Integer> deleteTeacherLecture(@PathVariable Integer lectureId) {
        return Result.succeed(teacherLectureService.deleteTeacherLecture(lectureId));
    }


    /**
     * 修改名师讲堂状态
     *
     * @param lectureId lectureId
     * @param status    状态 0-不显示 1-显示
     * @return teacherId
     */
    @PutMapping(value = "/teacher-lecture/{lectureId}/status/{status}", produces = "application/json; charset=utf-8")
    @ApiOperation(value = " 修改名师讲堂状态", notes = " 修改名师讲堂状态", produces = "application/json")
    public Result<Integer> updateTeacherLectureStatus(@PathVariable Integer lectureId, @PathVariable Integer status) {
        return Result.succeed(teacherLectureService.updateTeacherLectureStatus(lectureId, status));
    }
}
